package org.example.Day3.fanxing;

import java.util.ArrayList;
import java.util.Objects;

class  Car{ }
class BENZ extends Car{}
class BWN extends Car{}
public class Test1 {
    public static void main(String[] args){
        //不管是什么类型都能接收
        ArrayList<BWN> list1 = new ArrayList<>();
        ArrayList<BENZ> list2 = new ArrayList<>();
        ArrayList<String > list3 = new ArrayList<>();
        test1(list1);
        test1(list2);
        test1(list3);


        //集合中只能是Car的子类才能被接收
        ArrayList<Car> list4 =new ArrayList<>();
        ArrayList<BWN> list5 = new ArrayList<>();
        test2(list4);
        test2(list5);

        //只能是car的父类才能被接收
        ArrayList<Car> list6 =new ArrayList<>();
        ArrayList<Object> list7 = new ArrayList<>();
        test3(list6);
        test3(list7);
    }
    public static void test1(ArrayList<?> list){

    }
    public static void test2(ArrayList<? extends Car> list){

    }
    public static void test3(ArrayList<? super Car>list){

    }

}
